<template>
    <div>
        <HomeNav></HomeNav>     
        <TwoTitle></TwoTitle>
        <ListOnePage :list="arr2"  :arr1="arr1"></ListOnePage>
        <!-- <ListTwo ></ListTwo> -->
        <div class="poc">动态路由模拟tab切换第一次进来有小bg未能解决
            <p>应为Update没有写next模拟出来hash值不变数据也能传参</p>
            <p>刷新的时候会重新传网页头部的参数，会返回第一次进来的页面</p>
            <p>loading。。。。。。</p>
        </div>
    </div>
</template>
<script>
import HomeNav from "../components/Home/HomeNav.vue";
export default {
    components: { HomeNav },
    data() {
        return {
            arr1: [],
            arr2: [],
        };
    },
    async created() {
        // console.log(this);
        // console.log(this.$route.params);
        for (let index = 1; index < 15; index++) {
            // console.log(typeof index);
            // let ob = {page:index,...this.$route.params}
            let data = await this.$API.ListAPI.GetList({
                page: index,
                ...this.$route.params,
            });
            // console.log(index);
            if (data.length>1) {
                // console.log(data);
                this.arr1.push(data)
                this.arr2.push(data[0].type_two)
            }
        }
    },
    // beforeRouteUpdate(()=>{})
    async beforeRouteUpdate (to, from, next) {
        // console.log(to);
        // console.log(from);
        this.arr1=[]
        this.arr2=[]
        for (let index = 1; index < 15; index++) {
            // console.log(typeof index);
            // let ob = {page:index,...this.$route.params}
            let data = await this.$API.ListAPI.GetList({
                page: index,
                ...to.params,
            });
            // console.log(index);
            if (data.length>1) {
                // console.log(data);
                this.arr1.push(data)
                this.arr2.push(data[0].type_two)
            }
        }
        this.$route.params.type_one=to.params.type_one
        console.log(this.$route.params.type_one);
    }

};
</script>

<style scoped>
.poc{
    position: fixed;
    top: 0%;
    left: 5%;
}
</style>